package com.szrt.java.day20170109.demo07;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;


/**
 * 不会调试的程序员不是好程序员
 * @author zsrt
 *
 */
public class MapTest {
	
	public static void main(String[] args) {
		
		
		Student hb = new Student();
		hb.setName("胡斌");
		hb.setAge(24);
		hb.setPhone("18676758812");
		
		Student lh = new Student();
		lh.setName("刘浩");
		lh.setAge(24);
		lh.setPhone("15766472216");
		
		Student cg = new Student();
		cg.setName("陈皋");
		cg.setAge(23);
		cg.setPhone("18617067326");
		
		Map<String,Student> map=null;
		map= new HashMap<String,Student>();
		
		map.put("hubin", hb);
		map.put("liuhao", lh);
		map.put("chengao", cg);
		
		//在类的对象上调用方法  不是在类上面调用方法。  凡是红色加粗而且是大写 是类  。类后面些小的是对象
		Set<String> set = map.keySet();
		//String[] set = new String[]{"hubin","liuhao","chengao"};
		
		for(String key:set){
			Student value =map.get(key);
			System.out.println("key="+key + "\t value=[" +value +"]");
		}
		
		Iterator<String> it = set.iterator();
		
		while(it.hasNext()){
			
			String key   = it.next();
			Student value = map.get(key);
			System.out.println("key="+key + "\t value=[" +value +"]");
		}
		
	}

}
